package com.wwwzh.himalayafm.fragment.subfragment;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.wwwzh.himalayafm.R;

import java.util.List;
import java.util.Map;

public class SubHistoryRecAdapter extends RecyclerView.Adapter<SubHistoryRecAdapter.ViewHolder> {
    private Context context;
    private List<Map<String, String>> list;

    public SubHistoryRecAdapter(Context paramContext, List<Map<String, String>> paramList) {
        this.context = paramContext;
        this.list = paramList;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup paramViewGroup, int paramInt) {
        return new ViewHolder(LayoutInflater.from(context).inflate(R.layout.layout_subhisitem, paramViewGroup, false));
    }
    @Override
    public void onBindViewHolder(ViewHolder holder, int paramInt) {
        holder.subHisItemTitle.setText((CharSequence) ((Map) this.list.get(paramInt)).get("title"));
        holder.subHisItemLastListen.setText((CharSequence) ((Map) this.list.get(paramInt)).get("lastListen"));
        holder.subHisItemLastTime.setText((CharSequence) ((Map) this.list.get(paramInt)).get("lastTime"));
    }
    @Override
    public int getItemCount() {
        return this.list.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        private ImageView subHisItemImg;
        private TextView subHisItemLastListen;
        private TextView subHisItemLastTime;
        private TextView subHisItemTitle;
        public ViewHolder(View paramView) {
            super(paramView);
            this.subHisItemImg = ((ImageView) paramView.findViewById(R.id.SubHisItem_IV));
            this.subHisItemTitle = ((TextView) paramView.findViewById(R.id.SubHisItemTitle_TV));
            this.subHisItemLastListen = ((TextView) paramView.findViewById(R.id.SubHisItemLastListen_TV));
            this.subHisItemLastTime = ((TextView) paramView.findViewById(R.id.SubHisItemLastTime_TV));
        }
    }
}

